#pragma once

#include "MGUI_Types.h"
#include "MGUI_LookFeel.h"
#include "MGUI_Helper.h"
#include "MGUI_Serializer.h"
#include "MGUI_Layout.h"
#include "MGUI_Clipboard.h"
#include "MGUI_FontManager.h"
#include "MGUI_SkinManager.h"
#include "MGUI_InputManager.h"


namespace Myway {

	class MGUI_ENTRY MGUI_Engine
	{
		DECLARE_SINGLETON(MGUI_Engine);

	public:
		MGUI_Engine(int w, int h);
		~MGUI_Engine();

		// Layout
		void AddLayout(MGUI_Layout * _layout);
		void RemoveLayout(MGUI_Layout * _layout);
		void RemoveAllLayout(bool _delete = true);
		MGUI_Layout * GetLayout(const TString128 & name);

		void OnResize(int w, int h);
		void Update();
		void Render();

		const MGUI_Rect & GetRect() { return mRect; }

		MGUI_Widget * GetWidget(int _x, int _y);

		void NotifySortLayout();

	protected:
		MGUI_Helper * mHelper;

		Array<MGUI_Layout *> mLayouts;
		Array<MGUI_LookFeel *> mLookFeels;

		MGUI_Rect mRect;

		MGUI_LookFeelManager mLookFeelManager;

		MGUI_Clipboard mCilpboard;

		MGUI_FontManager mFontManager;

		MGUI_SkinManager mSkinManager;

		MGUI_InputManager mInputManager;
	};

}